﻿using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
using System.Linq.Expressions;
using GrayParrot.Web.Controls;

namespace $rootnamespace$
{
	public class $safeitemrootname$ : ResultSet</*<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->*/>
	{
        public $safeitemrootname$(DTParameters param, IQueryable</*<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->*/> result)
            : base(param, result)
        {
        }

        /* example of override of the ApplyGeneralFilter 
         * Use this method template if don't want to use an external filter class...
        public override Expression<Func<<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->, bool>> ApplyGeneralFilter(string searchPattern)
        {
            var predicate = PredicateBuilder.False<<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->>();

            if (!string.IsNullOrWhiteSpace(searchPattern))
            {
                predicate = predicate.Or(im => im.SportId != null && im.SportId.ToString().Contains(searchPattern));
                predicate = predicate.Or(im => im.OddsTypeId != null && im.OddsTypeId.ToString().Contains(searchPattern));
            }

            return predicate;
        }
        
        // example of use of external filter class for ApplyGeneralFilter...
        public override Expression<Func<<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->, bool>> ApplyGeneralFilter(string searchPattern)
        {
            MyGeneralFilterBag m_generalFilter = new MyGeneralFilterBag();
            m_generalFilter.SearchPattern = searchPattern;

            return m_generalFilter.SetUpFilter();
        }
        */

        /* example of override of the ApplyGeneralColumnsFilter 
         * Use this method template if don't want to use an external filter class...
        public override Expression<Func<<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->, bool>> ApplyGeneralColumnsFilter(List<string> columnSearch)
        {
            var predicate = PredicateBuilder.True<<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->>();

            int m_sport = int.Parse(columnSearch[ColumnIndex]);
            int m_oddsType = int.Parse(columnSearch[ColumnIndex]);

            if (m_sport != default(int))
            {
                predicate = predicate.And(im => im.SportId == m_sport);
            }

            if (m_oddsType != default(int))
            {
                predicate = predicate.And(im => im.OddsTypeId == m_oddsType);
            }

            return predicate;
        }
        
        // example of use of external filter class for ApplyGeneralColumnFilter... 
        public override Expression<Func<<!-- PUT HERE THE TYPE OF OBJECT YOU WANT TO FILTER -->, bool>> ApplyGeneralColumnsFilter(List<string> columnSearch)
        {
            MyColumnsFilterBag m_filterBag = new MyColumnsFilterBag();

            m_filterBag.IdAvvenimento = m_filterBag.GetValueOrDefault<int>(columnSearch[ColumnIndex]);
            m_filterBag.Descrizione = columnSearch[ColumnIndex];
            m_filterBag.Data = m_filterBag.ManageDates(columnSearch[ColumnIndex]);

            return m_filterBag.SetUpFilter();
        }          
        */
	}
}
